import 'dart:ui';

// Created by wangliang on 2025/2/22.

class CommonColor {
  static Color std001 = const Color(0xFF313233);
  static Color std002 = const Color(0xFF626466);
  static Color std003 = const Color(0xff939699);
  static Color c_3d3d3d = const Color(0xff3D3D3D);

  static Color std007 = const Color(0xFFCCCCCC);
  static Color globalBg = const Color(0xFFF3F7FC);

  static Color fromHex(String hex, {String defaultValue = "#FFFFFF"}) {
    try {
      // 去除 # 符号
      hex = hex.replaceAll("#", "");
      // 如果颜色代码只有 6 位，添加不透明前缀 0xFF
      if (hex.length == 6) {
        hex = "FF$hex";
      }
      // 将十六进制字符串转换为整数
      int colorInt = int.parse(hex, radix: 16);
      // 创建 Color 对象
      return Color(colorInt);
    } catch (e) {
      return fromHex(defaultValue);
    }
  }
}
